clear all
*cap log close
set more off
set seed 603

* naive OLS regression table ----------------------------------------------------------
#delimit ;
global cov = "female age agesq age_miss race_b race_h race_o race_u priorprison local
logzip zipincome_miss logprice veh_miss speed_py1 other_py1 crashany_py1" ;
#delimit cr

* setup data ------------------------------
use "${data}/out/4-main", clear
cap gen harsh   = (speedd>=10)
cap gen fine100 = fine/100
label var harsh "Harsh Fine"
label var fine100 "Fine (\\$100s)"
gen Y = cite_ny1

* store sample ----------------------------
reghdfe Y fine100 ${cov}, absorb(officerid totfe) vce(cluster officerid)
keep if e(sample)==1

* regression estimates ----------------------
eststo clear

eststo est1: reghdfe Y fine100, absorb(totfe) vce(cluster officerid)
qui summ Y if e(sample)==1 & discount == 1
local m = r(mean)
local m : di %5.3f `m'
qui estadd local mu  = "`m'"
qui estadd local cov = "No"
qui estadd local ofe = "No"
qui estadd local sfe  = "Yes"

eststo est2: reghdfe Y fine100, absorb(officerid totfe) vce(cluster officerid)
qui summ Y if e(sample)==1 & discount == 1
local m = r(mean)
local m : di %5.3f `m'
qui estadd local mu  = "`m'"
qui estadd local cov = "No"
qui estadd local ofe = "Yes"
qui estadd local sfe  = "Yes"

eststo est3: reghdfe Y fine100 ${cov}, absorb(totfe) vce(cluster officerid)
qui summ Y if e(sample)==1 & discount == 1
local m = r(mean)
local m : di %5.3f `m'
qui estadd local mu  = "`m'"
qui estadd local cov = "Yes"
qui estadd local ofe = "No"
qui estadd local sfe  = "Yes"

eststo est4: reghdfe Y fine100 ${cov}, absorb(officerid totfe) vce(cluster officerid)
qui summ Y if e(sample)==1 & discount == 1
local m = r(mean)
local m : di %5.3f `m'
qui estadd local mu  = "`m'"
qui estadd local cov = "Yes"
qui estadd local ofe = "Yes"
qui estadd local sfe  = "Yes"

* post to LaTeX table ----------------------------
#delimit ;
esttab * using "${out}/apx_deter/table_naive.tex", nostar
keep(fine100) wrap varwidth(20) se stats(mu cov ofe sfe N, 
	label("Mean" "Controls" "Officer FE" "Beat-Shift FE" "Observations")) 
mtitles("Reoffend" "Reoffend" "Reoffend" "Reoffend") label fragment replace  ;
#delimit cr 
* ------------------------------------------------------------------------------------------





